package com.itbaima.csmall.stock.webapi.quartz.config;

import com.itbaima.csmall.stock.webapi.quartz.rabbit.RabbitMQJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p>Quartz配置</p>
 *
 * @author Chen
 * @since 2023/3/3 16:13:13
 */
@Configuration
public class QuartzConfig {

    @Bean
    public JobDetail jobDetail() {
        return JobBuilder.newJob(RabbitMQJob.class)
                .withIdentity("myStock")
                .storeDurably()
                .build();
    }

    @Bean
    public Trigger setTrigger() {
        CronScheduleBuilder cron = CronScheduleBuilder.cronSchedule("0/10 * * * * ?");
        return TriggerBuilder.newTrigger()
                .forJob(jobDetail())
                .withIdentity("myStockTrigger")
                .withSchedule(cron)
                .build();
    }

}
